using Godot;

public partial class VictoryLayer : CanvasLayer
{
    private static TextureRect _star1;
    private static TextureRect _star2;
    private static TextureRect _star3;
    private static Label _survivedLabel;
    private static Label _healthLabel;
    private static Label _moneyLabel;

    public static PlayerBase BaseLevelCs;
    public static Bank BankCs;


    public override void _Ready()
    {
        _star1 = GetNode<TextureRect>("%Star1");
        _star2 = GetNode<TextureRect>("%Star2");
        _star3 = GetNode<TextureRect>("%Star3");
        _survivedLabel = GetNode<Label>("%SurvivedLabel");
        _healthLabel = GetNode<Label>("%HealthLabel");
        _moneyLabel = GetNode<Label>("%MoneyLabel");
        BaseLevelCs = (PlayerBase)GetTree().GetFirstNodeInGroup("PlayerBase");
        BankCs = (Bank)GetTree().GetFirstNodeInGroup("bank");
    }

    public void Victory()
    {
        // 将Visible属性设置为true
        Visible = true;

        // 如果当前生命值等于最大生命值
        if (BaseLevelCs.MaxHealth == BaseLevelCs.CurrentHealth)
        {
            // 将_star2的颜色设置为白色
            _star2.Modulate = new Color(Colors.White);
            // 将_healthLabel的Visible属性设置为true
            _healthLabel.Visible = true;
        }

        // 如果当前金币数大于等于500
        if (BankCs.CurrGold >= 500)
        {
            // 将_star3的颜色设置为白色
            _star3.Modulate = new Color(Colors.White);
            _moneyLabel.Visible = true;
        }
    }

    // 当重玩按钮被点击时调用
    public void OnRetryButtonClick()
    {
        // 打印重玩
        GD.Print("重玩");
        GetTree().ReloadCurrentScene();
    }

// 当退出按钮被点击时调用此方法
    public void OnQuitButtonClick()
    {
        // 打印退出
        GD.Print("退出");
        GetTree().Quit();
    }

// 当点击下一关按钮时调用此方法
    public void OnNextButtonClick()
    {
        // 打印"下一关"
        GD.Print("下一关");
    }
}